<template>
  <div>
    <div class="header">
      <!-- <img src="@/assets/img/gongsilogo.png" style="height:100%" alt=""> -->
      <span class="mlt10">JAVA低代码开发：{{ javatitle }}</span>
      <span>名字：{{ name }}</span>
    </div>
    <i
      :class="leftOrRight1"
      class="fiexleft"
      :style="styleObj1"
      @click="handleleft1"
    ></i>
    <i
      :class="leftOrRight2"
      class="fiexright"
      :style="styleObj2"
      @click="handleleft2"
    ></i>
    <el-container style="height: calc(100vh - 65px)">
      <el-aside width="256px" class="leftAside" ref="leftAside">
        <div class="talin">
          <el-input
            v-model="iptVal"
            placeholder="请输入关键字过滤"
            style="width: 94%"
            clearable
          ></el-input>
        </div>
        <div class="elCollapseStyle">
          <el-collapse v-model="activeName" accordion>
            <el-collapse-item
              :name="index + 1"
              v-for="(list, index) in compallLists"
              :key="index"
            >
              <span class="collapse-title" slot="title">{{ list.title }}</span>
              <div class="setctionBox">
                <div
                  v-for="(child, idx) in list.children"
                  :key="idx"
                  :style="cursorComputed(child, true)"
                >
                  <a
                    :style="cursorComputed(child, false)"
                    @click="handleState(child.title, child.svg)"
                  >
                    <svg-icon :icon-class="child.svg" style="font-size: 20px" />
                    <span
                      :style="{
                        color: activeState == child.title ? '#ffba00' : 'white',
                      }"
                      >{{ child.title }}</span
                    >
                  </a>
                </div>
              </div>
            </el-collapse-item>
          </el-collapse>
        </div>
      </el-aside>
      <el-main class="elMain">
        <ul
          v-show="activeFlag"
          class="contextmenu"
          :style="{
            left: contexObjtmenu.left + 'px',
            top: contexObjtmenu.top + 'px',
          }"
        >
          <li @click="handleXDelete(contexObjtmenu.name, contexObjtmenu.index)">
            关闭当前标签页
          </li>
          <li @click="handleOtherTab(contexObjtmenu.item)">关闭其他标签页</li>
          <li @click="handleAllTab">关闭所有标签页</li>
        </ul>
        <div class="box_Item" ref="box_Item" @scroll="closeMenu">
          <div
            v-for="(titleItem, index) in titleLists"
            :key="index"
            class="itemClass"
            :style="activeComputed(titleItem.name)"
            @click="handleItem(titleItem)"
            @contextmenu.prevent="
              ($event) => openMenu(titleItem, index, $event)
            "
            :id="titleItem.svg"
          >
            <el-tooltip
              class="item"
              effect="dark"
              :content="titleItem.name"
              placement="top"
            >
              <div style="display: flex">
                <div
                  style="
                    max-width: 150px;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                  "
                >
                  {{ titleItem.name }}
                </div>
                <span
                  class="deleteX"
                  v-show="titleItem.name != 'API列表'"
                  @click.stop="handleXDelete(titleItem.name, index)"
                  >x</span
                >
              </div>
            </el-tooltip>
          </div>
        </div>
        <div style="height: calc(100vh - 150px); overflow: auto">
          <keep-alive :include="title_Lists">
            <component
              :is="currentComponent"
              :ref="currentComponent"
              :[_formData_]="formData"
              :[mode_Title]="modeTitle"
            ></component>
          </keep-alive>
        </div>
        <div class="myFooter" ref="myFooter">
          <div class="resizeTOPBar" ref="resizeTOPBar" />
          <i :class="topOrBottom" class="bottomOrTop" @click="handleTOP"></i>
          <div class="childClass" v-if="topOrBottom === 'el-icon-caret-bottom'">
            <div v-show="CompileerrorLists == '接口错误'" class="classError">
              接口错误
            </div>
            <div v-show="CompileerrorLists != '接口错误'" style="height: 100%">
              <div v-show="CompileerrorLists[2]">
                编译结果：{{ CompileerrorLists[2] }}
              </div>
              <div
                class="successorerror"
                v-show="errorContent(CompileerrorLists).length"
              >
                <div
                  v-for="(item, index) in errorContent(CompileerrorLists)"
                  :key="index"
                  style="margin-bottom: 10px"
                >
                  {{ item }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </el-main>
      <el-aside width="350px" class="rightAside" ref="rightAside">
        <div class="classFixed" ref="classFixed">
          <!-- style="margin-top: 20px; width: 23%" -->
          <el-button
            type="primary"
            style="margin-top: 20px"
            @click="handleClick"
            :loading="treeLoading"
            >{{ btnName }}</el-button
          >
          <el-button
            type="primary"
            style="margin-top: 20px"
            @click="handleCompile"
            :loading="CompileLoading"
            >编译</el-button
          >
          <el-button
            type="primary"
            style="margin-top: 20px"
            @click="handleDeploy"
            :loading="deployLoading"
            >部署</el-button
          >
          <div>
            <el-input
              placeholder="输入关键字进行过滤"
              v-model="filterText"
              clearable
              style="width: 70%; margin-top: 10px; margin-bottom: 5px"
            ></el-input>
          </div>
        </div>

        <!-- 不使用虚拟滚动时只需去掉height参数即可 -->
        <vue-easy-tree
          ref="tree"
          node-key="id"
          height="calc(100vh - 200px)"
          :data="treeData"
          :props="defaultProps"
          highlight-current
          :filter-node-method="filterNode"
          @node-click="handleNodeClick"
          @node-expand="handleNodeExpand"
          @node-collapse="handleNodeCollapse"
          :default-expanded-keys="expandLists"
          class="el-scrollbar"
          id="elScrollbar"
          v-if="isRefresh"
          v-loading="treeLoading"
          element-loading-background="rgba(0, 0, 0, 0.8)"
        >
          <div slot-scope="{ node, data }" style="width: 100%">
            <el-popover
              placement="left"
              maxWidth="400"
              trigger="hover"
              :disabled="!data.chName"
            >
              <div class="www">
                <div v-for="(child, index) in tooltipCom(data)" :key="index">
                  {{ child }}
                </div>
              </div>
              <span slot="reference">
                <svg-icon
                  :style="{ fontSize: data.type == 5 ? '20px' : '16px' }"
                  :icon-class="
                    [1, 2, 3].includes(data.type)
                      ? 'wenjianjia'
                      : [4].includes(data.type)
                      ? 'c图标'
                      : [5].includes(data.type)
                      ? 'i图标'
                      : [6].includes(data.type)
                      ? 'wenben'
                      : [7].includes(data.type)
                      ? 'm图标'
                      : [8].includes(data.type)
                      ? 'eIconse'
                      : ''
                  "
                />
                <a style="color: #999b9d" :id="data.name">{{ node.label }}</a>
              </span>
            </el-popover>
            <div
              style="display: inline-block"
              v-if="data.list && data.list.length"
              :class="data.name"
            >
              <el-tooltip content="全部展开" placement="top">
                <span @click.stop="handleAllOpen(data)"
                  ><svg-icon
                    icon-class="openSvg"
                    style="font-size: 12px; margin: 0 10px"
                /></span>
              </el-tooltip>
              <el-tooltip content="全部收起" placement="top">
                <span @click.stop="handleClose(data)">
                  <svg-icon icon-class="closeSvg" style="font-size: 12px" />
                </span>
              </el-tooltip>
            </div>
          </div>
        </vue-easy-tree>

        <div class="resizeBar" ref="resizeRightBar" />
      </el-aside>
    </el-container>
    <addClass :addClassVisible="addClassVisible" v-if="addClassVisible" />
    <objService v-if="$store.state.user.objServicedelog" />
    <scheduledTasks
      :scheduledTasksVisible="scheduledTasksVisible"
      v-if="scheduledTasksVisible"
      @close="scheduledTasksVisible = false"
    />
    <scheduledFixedTasks
      :scheduledFixedTasksVisible="scheduledFixedTasksVisible"
      v-if="scheduledFixedTasksVisible"
      @close="scheduledFixedTasksVisible = false"
    />
    <el-dialog
      title="提示"
      :visible.sync="changeDialogVisible"
      width="30%"
      append-to-body
      :close-on-click-modal="false"
    >
      <el-radio v-model="changeRadio" label="1">添加同层</el-radio>
      <el-radio v-model="changeRadio" label="2">添加子层</el-radio>
      <span slot="footer" class="dialog-footer">
        <el-button @click="changeDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleChangeSure">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {
  SourceCodeTreeList,
  moduleModetTreeList,
  projectgetContent,
  configItemExist,
  deployMvn_install,
} from "@/api/lowcode";
import { getConfigDeploy } from "@/api/article";
import basicsssssComponents from "./basiComponents/index.vue";
import customComponents from "./databaseComponents/customComponents.vue";
import customQuery from "./databaseComponents/customQuery.vue";
import customUpdates from "./databaseComponents/customUpdates.vue";
import customDeletion from "./databaseComponents/customDeletion.vue";
import customApiSearch from "./databaseComponents/customApiSearch.vue";
import addClass from "./addClass.vue";
import scheduledTasks from "./timedTasksConponents/scheduledTasks.vue";
import scheduledFixedTasks from "./timedTasksConponents/scheduledFixedTasks.vue";
import objService from "./basiComponents/objService.vue";
import notificationComponents from "./NotifyComponent/notificationComponents.vue";
import keySettingsComponents from "./NotifyComponent/keySettingsComponents.vue";
import notificationListComponents from "./NotifyComponent/notificationListComponents.vue";
import addconfigurationComponents from "./NotifyComponent/addconfigurationComponents.vue";
import addSignature from "./NotifyComponent/addSignature.vue";
import emailSettings from "./NotifyComponent/emailSettings.vue";
import scheduledFixedTaskLists from "./timedTasksConponents/scheduledFixedTaskLists.vue";
import scheduledTaskslists from "./timedTasksConponents/scheduledTaskslists.vue";
import feignComponents from "./httpComponents/feignComponents.vue";
import addinterfaceComponents from "./httpComponents/addinterfaceComponents.vue";
import dependencysConfiguration from "./configurationManagement/dependencysConfiguration.vue";
import projectsConfiguration from "./configurationManagement/projectsConfiguration.vue";
import othersConfigurations from "./configurationManagement/othersConfigurations.vue";
import VueEasyTree from "@wchbrad/vue-easy-tree";
import "@wchbrad/vue-easy-tree/src/assets/index.scss";
import { mapGetters } from "vuex";
import { getOffsetTopToScrollParent } from "@/utils/index";
export default {
  components: {
    VueEasyTree,
    basicsssssComponents,
    customComponents,
    customQuery,
    customUpdates,
    customDeletion,
    customApiSearch,
    addClass,
    scheduledTasks,
    scheduledFixedTasks,
    objService,
    notificationComponents,
    keySettingsComponents,
    notificationListComponents,
    addconfigurationComponents,
    addSignature,
    emailSettings,
    scheduledFixedTaskLists,
    scheduledTaskslists,
    feignComponents,
    addinterfaceComponents,
    dependencysConfiguration,
    projectsConfiguration,
    othersConfigurations,
  },
  data() {
    return {
      CompileLoading: false,
      CompileerrorLists: [],
      treeScroll: 0,
      isRefresh: true,
      expandLists: [],
      deployLoading: false,
      treeLoading: false,
      //tab页需要缓存的组件列表
      tabNameLists: [
        // { name: "API列表", componentName: "basicsssssComponents" },
        // { name: "编辑API", componentName: "basicsssssComponents" },
        // { name: "接口逻辑", componentName: "basicsssssComponents" },
        { name: "数据库操作组件列表", componentName: "customComponents" },
        { name: "数据库查询组件", componentName: "customQuery" },
        { name: "数据库更新组件", componentName: "customUpdates" },
        { name: "数据库删除组件", componentName: "customDeletion" },
        { name: "数据库sql组件", componentName: "customApiSearch" },
        { name: "通知配置列表", componentName: "notificationListComponents" },
        {
          name: "新增短信或邮件通知模板",
          componentName: "notificationComponents",
        },
        { name: "短信通知密钥设置", componentName: "keySettingsComponents" },
        { name: "新增配置项", componentName: "addconfigurationComponents" },
        { name: "新增短信签名", componentName: "addSignature" },
        { name: "邮件通知设置", componentName: "emailSettings" },
        { name: "周期性定时任务列表", componentName: "scheduledTaskslists" },
        { name: "定时任务流程列表", componentName: "scheduledFixedTaskLists" },
        { name: "新增feign调用接口", componentName: "addinterfaceComponents" },
        { name: "feign调用接口列表", componentName: "feignComponents" },
        { name: "依赖配置", componentName: "dependencysConfiguration" },
        { name: "项目配置", componentName: "projectsConfiguration" },
        { name: "其他配置", componentName: "othersConfigurations" },
      ],
      activeFlag: false,
      contexObjtmenu: {
        left: 0,
        top: 0,
        item: null,
        name: "",
        index: 0,
      },
      activeitemName: "API列表",
      titleLists: [
        {
          name: "API列表",
          svg: "APItable",
        },
      ],
      isChildCirculate: true,
      isClickCom: false,
      changeRadio: "1",
      changeDialogVisible: false,
      iptVal: "",
      scheduledTasksVisible: false,
      scheduledonceTasksVisible: false,
      scheduledFixedTasksVisible: false,
      widthArray: ["数值格式化", "日期/时间比较"],
      javatitle: sessionStorage.getItem("developLowCodeTitle"),
      leftOrRight1: "el-icon-caret-left",
      leftOrRight2: "el-icon-caret-right",
      topOrBottom: "el-icon-caret-top",
      activeName: 1,
      allLists: [
        {
          title: "接口操作",
          children: [
            {
              svg: "APItable",
              title: "API列表",
            },
            {
              svg: "APIpre",
              title: "新增API",
            },
          ],
        },
        {
          title: "基础组件",
          children: [
            {
              svg: "ifDetermine",
              title: "条件判断",
            },
            {
              svg: "update-success",
              title: "循环控制",
            },
            {
              svg: "callingMethod",
              title: "调用方法",
            },
            {
              svg: "CreatingProperties",
              title: "创建属性",
            },
            {
              svg: "backCompoent",
              title: "返回组件",
            },
            {
              svg: "createInstance",
              title: "创建实例组件",
            },
            {
              svg: "BreakComponent",
              title: "打断当前循环组件",
            },
            {
              svg: "overCompoent",
              title: "结束循环组件",
            },
            {
              svg: "shilifuzhi",
              title: "实例赋值组件",
            },
            {
              svg: "logsvg",
              title: "控制台日志",
            },
            {
              svg: "daimaduan",
              title: "自定义代码段",
            },
          ],
        },
        {
          title: "数据库操作",
          children: [
            {
              svg: "dbsesSearch",
              title: "查询",
            },
            {
              svg: "dbsesUpdate",
              title: "更新",
            },
            {
              svg: "dbsesdelete",
              title: "删除",
            },
            {
              svg: "dbsesSQL",
              title: "SQL",
            },
          ],
        },
        {
          title: "方法与类操作",
          children: [
            {
              svg: "addfangfa",
              title: "增加方法",
            },
            {
              svg: "vosvg",
              title: "新增vo",
            },
            {
              svg: "addClasswe",
              title: "新增类",
            },
          ],
        },
        {
          title: "集合操作",
          children: [
            {
              svg: "createCollection",
              title: "创建集合",
            },
            {
              svg: "jiheyuanshu",
              title: "集合元素添加组件",
            },
            {
              svg: "jihesvg",
              title: "按集合下标获取元素",
            },
            {
              svg: "tiaojiansaixuan",
              title: "按条件筛选元素",
            },
            {
              svg: "jihexiaobiaoshanchu",
              title: "按集合下标删除",
            },
            {
              svg: "shuaixuansvg",
              title: "按条件筛选删除",
            },
          ],
        },
        {
          title: "数值操作",
          children: [
            {
              svg: "jichuyunsuan",
              title: "基础运算",
            },
            {
              svg: "gaojieyunsuan",
              title: "高阶运算",
            },
            {
              svg: "geshihuasvg",
              title: "数值格式化",
            },
          ],
        },
        {
          title: "字符串操作组件",
          children: [
            {
              svg: "stringcaozuo",
              title: "字符串操作",
            },
            {
              svg: "zifuchuanpinjie",
              title: "字符串拼接",
            },
          ],
        },
        {
          title: "日期与时间操作",
          children: [
            {
              svg: "geshizhuanhuansvg",
              title: "格式转换",
            },
            {
              svg: "riqiyunsuansvg",
              title: "日期运算",
            },
            {
              svg: "shijianbijiaosvg",
              title: "日期/时间比较",
            },
          ],
        },
        {
          title: "数据库操作组件管理",
          children: [
            {
              svg: "dbseCaozuo",
              title: "数据库操作组件列表",
            },
            {
              svg: "dbseSearch",
              title: "数据库查询组件",
            },
            {
              svg: "dbseUpdate",
              title: "数据库更新组件",
            },
            {
              svg: "dbsedelete",
              title: "数据库删除组件",
            },
            {
              svg: "dbseSQL",
              title: "数据库sql组件",
            },
          ],
        },
        {
          title: "消息通知",
          children: [
            {
              svg: "duanxintongzhi",
              title: "短信通知",
            },
            {
              svg: "emailNotice",
              title: "邮件通知",
            },
          ],
        },
        {
          title: "消息通知配置管理",
          children: [
            {
              svg: "tongzhiliebiao",
              title: "通知配置列表",
            },
            {
              svg: "duanxinmoban",
              title: "新增短信或邮件通知模板",
            },
            {
              svg: "verify",
              title: "短信通知密钥设置",
            },
            {
              svg: "peizhixiang",
              title: "新增配置项",
            },
            {
              svg: "qianming",
              title: "新增短信签名",
            },
            {
              svg: "youjiantongzhishezhi",
              title: "邮件通知设置",
            },
          ],
        },
        {
          title: "定时任务",
          children: [
            {
              svg: "dingshirenwu",
              title: "添加周期性定时任务",
            },
            {
              svg: "loudou",
              title: "添加一次性定时任务",
            },
            {
              svg: "renwuliucheng",
              title: "新增定时任务流程",
            },
            {
              svg: "zhouqixingliebiao",
              title: "周期性定时任务列表",
            },
            {
              svg: "dingshixingliebiao",
              title: "定时任务流程列表",
            },
          ],
        },
        {
          title: "第三方服务调用",
          children: [
            {
              svg: "http",
              title: "HTTP请求",
            },
            {
              svg: "biaodansw",
              title: "feign调用",
            },
          ],
        },
        {
          title: "微服务相关",
          children: [
            {
              svg: "addinterface",
              title: "新增feign调用接口",
            },
            {
              svg: "jiekouliebiao",
              title: "feign调用接口列表",
            },
          ],
        },
        {
          title: "配置管理",
          children: [
            {
              svg: "dependencyConfiguration",
              title: "依赖配置",
            },
            {
              svg: "projectConfiguration",
              title: "项目配置",
            },
            {
              svg: "otherConfigurations",
              title: "其他配置",
            },
          ],
        },
      ],
      isActive: false,
      addClassVisible: false,
      activeState: "API列表",
      currentComponent: "basicsssssComponents",
      defaultProps: {
        children: "list",
        label: "name",
      },
      treeData: [
        {
          id: 1,
          label: "一级 1",
          children: [
            {
              id: 4,
              label: "二级 1-1",
              children: [
                {
                  id: 9,
                  label: "三级 1-1-1",
                },
                {
                  id: 10,
                  label: "三级 1-1-2",
                },
              ],
            },
          ],
        },
        {
          id: 2,
          label: "一级 2",
          children: [
            {
              id: 5,
              label: "二级 2-1",
            },
            {
              id: 6,
              label: "二级 2-2",
            },
          ],
        },
        {
          id: 3,
          label: "一级 3",
          children: [
            {
              id: 7,
              label: "二级 3-1",
            },
            {
              id: 8,
              label: "二级 3-2",
            },
          ],
        },
      ],
      btnName: "显示源码",
      modeTitle: "显示源码",
      filterText: "",
      formData: { content: "", labeName: "" },
      // 左侧折叠数据中能在中间tab页显示的组件的svg
      isgaoliangLists: [
        "APItable",
        "APIpre",
        "vosvg",
        "addClasswe",
        "dbseCaozuo",
        "dbseSearch",
        "dbseUpdate",
        "dbsedelete",
        "dbseSQL",
        "tongzhiliebiao",
        "duanxinmoban",
        "verify",
        "peizhixiang",
        "qianming",
        "youjiantongzhishezhi",
        "dingshirenwu",
        "renwuliucheng",
        "zhouqixingliebiao",
        "dingshixingliebiao",
        "addinterface",
        "jiekouliebiao",
        "dependencyConfiguration",
        "projectConfiguration",
        "otherConfigurations",
      ],
    };
  },
  computed: {
    ...mapGetters(["name"]),
    errorContent() {
      return (CompileerrorLists) => {
        if (CompileerrorLists?.length) {
          const errorneirong = CompileerrorLists[1] || CompileerrorLists[0];
          console.log(errorneirong.split("\n"), 74520);
          return errorneirong.split("\n");
        }
        return [];
      };
    },
    tooltipCom() {
      return (item) => {
        return item.chName?.split("\r\n") ?? [];
      };
    },
    title_Lists() {
      const lists = this.titleLists.reduce((pre, next) => {
        const obj = this.tabNameLists.find(
          (item) => item.name == next.name || next.name.includes(item.name)
        );
        if (obj) {
          if (!pre.includes(obj.componentName)) {
            pre.push(obj.componentName);
          }
        }
        return pre;
      }, []);
      return lists;
    },
    activeComputed() {
      return (name) => {
        return {
          background: this.activeitemName === name ? "#1890ff" : "",
          color: this.activeitemName === name ? "white" : "#000",
        };
      };
    },
    compallLists() {
      return this.allLists.filter(
        (item) =>
          item.title.includes(this.iptVal) ||
          item.children.some((childItem) =>
            childItem.title.includes(this.iptVal)
          )
      );
    },
    _formData_() {
      return this.currentComponent === "basicsssssComponents"
        ? "formData"
        : null;
    },
    mode_Title() {
      return this.currentComponent === "basicsssssComponents"
        ? "modeTitle"
        : null;
    },
    styleObj1() {
      return {
        color: this.leftOrRight1 === "el-icon-caret-left" ? "white" : "#13192b",
        left: this.leftOrRight1 === "el-icon-caret-left" ? "230px" : "-16px",
      };
    },
    styleObj2() {
      return {
        color:
          this.leftOrRight2 === "el-icon-caret-right" ? "white" : "#13192b",
        right: this.leftOrRight2 === "el-icon-caret-right" ? "325px" : "-14px",
      };
    },
    cursorComputed() {
      return (child, flag) => {
        let cursor = "pointer";
        let opacity = "1";
        let pointer = "auto";

        if (child.svg === "addfangfa") {
          if (!this.isgaoliangLists.includes("addfangfa")) {
            cursor = "not-allowed";
            opacity = "0.3";
            pointer = "none";
          }
        } else {
          if (!this.isgaoliangLists.includes(child.svg)) {
            if (this.isClickCom) {
              const basicComponents =
                this.$refs.basicsssssComponents?.$refs.basicComponents;
              if (basicComponents.classType === "SERVICE_I") {
                cursor = "not-allowed";
                opacity = "0.3";
                pointer = "none";
              } else {
                if (
                  ["方法", "方法体"].includes(
                    basicComponents.addBasicObj.isMethodOrBody
                  )
                ) {
                  const componentType =
                    basicComponents.addBasicObj?.isMethodObjOrBody
                      ?.componentType;
                  // 打断当前循环组件和结束循环组件
                  if (["BreakComponent", "overCompoent"].includes(child.svg)) {
                    if (basicComponents.addBasicObj.isMethodOrBody === "方法") {
                      cursor = "not-allowed";
                      opacity = "0.3";
                      pointer = "none";
                    } else {
                      if (componentType != 3 && componentType != 2) {
                        const recursion2 = (methodBody, Body) => {
                          const obj = methodBody.find(
                            (item2) => item2.id === Body.parentId
                          );
                          if (obj) {
                            if (
                              obj.componentType != 3 &&
                              obj.componentType != 2
                            ) {
                              recursion2(methodBody, obj);
                            } else {
                              if (![1, 16, 17].includes(componentType)) {
                                cursor = "pointer";
                                opacity = "1";
                                pointer = "auto";
                              }
                            }
                          }
                        };
                        const recursion1 = (methodBody, Body) => {
                          const obj = methodBody.find(
                            (item2) => item2.id === Body.parentId
                          );
                          if (obj) {
                            if (
                              obj.componentType != 3 &&
                              obj.componentType != 2
                            ) {
                              if ([1, 16, 17].includes(obj.componentType)) {
                                const obj1 = methodBody.find(
                                  (item2) => item2.id === obj.parentId
                                );
                                if (obj1) {
                                  if (
                                    obj1.componentType == 3 ||
                                    obj1.componentType == 2
                                  ) {
                                    if (![1, 16, 17].includes(componentType)) {
                                      cursor = "pointer";
                                      opacity = "1";
                                      pointer = "auto";
                                    }
                                  } else {
                                    recursion2(methodBody, obj1);
                                  }
                                }
                              } else {
                                recursion1(methodBody, obj);
                              }
                            } else {
                              if (![1, 16, 17].includes(componentType)) {
                                cursor = "not-allowed";
                                opacity = "0.3";
                                pointer = "none";
                              }
                            }
                          } else {
                            cursor = "not-allowed";
                            opacity = "0.3";
                            pointer = "none";
                          }
                        };

                        recursion1(
                          basicComponents.addBasicObj.item.methodBody,
                          basicComponents.addBasicObj.isMethodObjOrBody
                        );
                      } else {
                        cursor = "not-allowed";
                        opacity = "0.3";
                        pointer = "none";
                        const parenttiaojian = this.isttiaojianpanduan(
                          basicComponents.addBasicObj.item.methodBody,
                          basicComponents.addBasicObj.isMethodObjOrBody
                        );
                        if (parenttiaojian?.flag) {
                          if (
                            this.istxunhuankongzhi(
                              basicComponents.addBasicObj.item.methodBody,
                              parenttiaojian.obj
                            )
                          ) {
                            cursor = "pointer";
                            opacity = "1";
                            pointer = "auto";
                          }
                        }
                      }
                    }
                  }
                  if (basicComponents.classType !== "SERVICE") {
                    if (
                      [
                        "dbsesSearch",
                        "dbsesUpdate",
                        "dbsesdelete",
                        "dbsesSQL",
                      ].includes(child.svg)
                    ) {
                      cursor = "not-allowed";
                      opacity = "0.3";
                      pointer = "none";
                    }
                  }
                }
              }
            } else {
              cursor = "not-allowed";
              opacity = "0.3";
              pointer = "none";
            }
          }
        }
        return flag
          ? { cursor, opacity }
          : {
              "pointer-events": pointer,
              width: this.widthArray.includes(child.title) ? "85px" : "55px",
            };
      };
    },
  },
  provide() {
    return {
      SourceCodeTreeList: this.SourceCodeTreeList,
      moduleModetTreeList: this.moduleModetTreeList,
      btnName: this.btnName,
    };
  },
  mounted() {
    sessionStorage.setItem("activeState", "API列表");
    this.moduleModetTreeList();
    this.$nextTick(() => {
      this.$refs.basicsssssComponents.$refs.basicComponents.getList();
    });
    this.resizeRightAndMedium();
    this.resizeTopAndMedium();
    document.body.addEventListener("click", this.closeMenu);

    const scrollTreeDom = document.querySelector(".vue-recycle-scroller");
    scrollTreeDom.addEventListener("scroll", this.handleScroll);
  },
  beforeDestroy() {
    document.body.removeEventListener("click", this.closeMenu);

    const scrollTreeDom = document.querySelector(".vue-recycle-scroller");
    scrollTreeDom?.removeEventListener("scroll", this.handleScroll);
  },
  methods: {
    handleScroll(event) {
      this.treeScroll = event.target.scrollTop;
      console.log(this.treeScroll, 4520);
    },
    handleNodeExpand(data) {
      this.expandLists.push(data.id);
      this.expandLists = [...new Set([...this.expandLists])];
      console.log(this.expandLists, "展开");
    },
    handleNodeCollapse(data) {
      const ids = [];
      ids.push(data.id);
      this.re_cursion(data.list, ids);
      ids.forEach((childId) => {
        this.expandLists = this.expandLists.filter((id) => id != childId);
      });
      console.log(data, this.expandLists, "收起");
    },
    handleAllOpen(data) {
      const ids = [];
      this.re_cursion(data.list, ids);
      this.expandLists = [...new Set([...this.expandLists, ...ids])];
    },
    handleClose(data) {
      const ids = [];
      ids.push(data.id);
      this.re_cursion(data.list, ids);
      ids.forEach((childId) => {
        this.expandLists = this.expandLists.filter((id) => id != childId);
      });
      console.log(data, this.expandLists, 74520);

      this.isRefresh = false;
      this.$nextTick(() => {
        this.isRefresh = true;
        setTimeout(() => {
          const scrollTreeDom = document.querySelector(".vue-recycle-scroller");
          scrollTreeDom.addEventListener("scroll", this.handleScroll);
          const wedom = document.querySelector(`.vue-recycle-scroller`);
          wedom.scrollTop = this.treeScroll;
          console.log(this.treeScroll, 630);
        });
      });
    },
    re_cursion(lists, ids) {
      lists?.forEach((item) => {
        ids.push(item.id);
        if (Array.isArray(item.list)) {
          this.re_cursion(item.list, ids);
        }
      });
    },
    async handleCompile() {
      try {
        this.CompileLoading = true;
        const res = await deployMvn_install(
          sessionStorage.getItem("developLowCodeId")
        );
        if (res?.code == 200) {
          this.CompileerrorLists = res.data;
        } else {
          this.CompileerrorLists = "接口错误";
        }
      } finally {
        this.CompileLoading = false;
      }
    },
    async handleDeploy() {
      try {
        this.deployLoading = true;
        const res = await getConfigDeploy(
          sessionStorage.getItem("developLowCodeId")
        );
        if (res.code == 200) {
          if (res.data) {
            this.$message({
              message: "部署成功",
              type: "success",
            });
          } else {
            this.$message({
              message: "部署失败",
              type: "warning",
            });
          }
        }
      } catch (err) {
        this.$message({
          message: "部署失败",
          type: "warning",
        });
      } finally {
        this.deployLoading = false;
      }
    },
    closeMenu(e) {
      this.activeFlag = false;
      // if (e) {
      //   if (!e.target.closest(".ssdw")) {
      //     this.$nextTick(() => {
      //       this.$refs.tree.setCurrentKey();
      //     });
      //   }
      // }
    },
    handleOtherTab(item) {
      this.titleLists = [
        {
          name: "API列表",
          svg: "APItable",
        },
        item,
      ];
      this.handleItem(item);
    },
    handleAllTab() {
      this.titleLists = [
        {
          name: "API列表",
          svg: "APItable",
        },
      ];
      this.handleItem(this.titleLists[0]);
    },
    openMenu(item, index, e) {
      this.activeFlag = true;
      this.contexObjtmenu.left = e.clientX;
      this.contexObjtmenu.top = e.clientY;
      this.contexObjtmenu.item = item;
      this.contexObjtmenu.name = item.name;
      this.contexObjtmenu.index = index;
    },
    resizeTopAndMedium() {
      const resizeElement = document.querySelector(".myFooter");
      this.$refs["resizeTOPBar"].onmousedown = (e) => {
        resizeElement.style.transition = "none";
        // left初始宽度
        const oldHeight = resizeElement.offsetHeight;
        // 点击鼠标初始X值
        const startY = e.clientY;
        document.onmousemove = (e) => {
          // 当前鼠标X值
          const endY = e.clientY;
          // 当前鼠标在X轴移动的距离
          const distance = startY - endY;
          // left-top当前高度
          let newHeight = oldHeight + distance;
          // 最小宽度是350
          if (newHeight < 300) {
            newHeight = 300;
          }
          // 设置dom样式
          resizeElement.style.height = `${newHeight}px`;
        };
        document.onmouseup = () => {
          document.onmousemove = null;
          document.onmouseup = null;
          resizeElement.style.transition = "all 1s ease";
        };
        return false;
      };
    },
    resizeRightAndMedium() {
      const resizeElement = document.querySelector(".rightAside");
      const rightElement = document.querySelector(".fiexright");
      this.$refs["resizeRightBar"].onmousedown = (e) => {
        this.$refs.rightAside.$el.style.transition = "none";
        // left初始宽度
        const oldWidth = resizeElement.offsetWidth;
        // 右侧尖叫图标初始宽度
        const oldfiexrightWidth = parseFloat(rightElement.style.right);
        // 点击鼠标初始X值
        const startX = e.clientX;
        document.onmousemove = (e) => {
          // 当前鼠标X值
          const endX = e.clientX;
          // 当前鼠标在X轴移动的距离
          const distance = startX - endX;
          // left-top当前高度
          let newWidth = oldWidth + distance;
          let newfiexrightWidth = oldfiexrightWidth + distance;
          // 最小宽度是350
          if (newWidth <= 350) {
            newWidth = 350;
          }
          if (newfiexrightWidth <= 325) {
            newfiexrightWidth = 325;
          }
          // 设置dom样式
          resizeElement.style.width = `${newWidth}px`;
          rightElement.style.right = `${newfiexrightWidth}px`;
        };
        document.onmouseup = () => {
          document.onmousemove = null;
          document.onmouseup = null;
          this.$refs.rightAside.$el.style.transition = "all 1s ease";
        };
        return false;
      };
    },
    handleleft1() {
      if (this.leftOrRight1 === "el-icon-caret-right") {
        this.leftOrRight1 = "el-icon-caret-left";
        this.$refs.leftAside.$el.style.width = "256px";
      } else {
        this.leftOrRight1 = "el-icon-caret-right";
        this.$refs.leftAside.$el.style.width = "0px";
      }
    },
    handleTOP() {
      if (this.topOrBottom === "el-icon-caret-bottom") {
        this.topOrBottom = "el-icon-caret-top";
        document.querySelector(".myFooter").style.height = "1px";
        document.querySelector(".bottomOrTop").style.top = "-27px";
      } else {
        this.topOrBottom = "el-icon-caret-bottom";
        document.querySelector(".myFooter").style.height = "300px";
        document.querySelector(".bottomOrTop").style.top = "-15px";
      }
    },
    handleleft2() {
      if (this.leftOrRight2 === "el-icon-caret-right") {
        this.leftOrRight2 = "el-icon-caret-left";
        this.$refs.rightAside.$el.style.width = "0px";
        this.$refs.classFixed.style.opacity = "0";
        this.$refs.classFixed.style.transform = "translateX(270px)";
      } else {
        this.leftOrRight2 = "el-icon-caret-right";
        this.$refs.rightAside.$el.style.width = "350px";
        this.$refs.classFixed.style.opacity = "1";
        this.$refs.classFixed.style.transform = "translateX(0)";
      }
    },
    async handletemplateBlur(configItem) {
      const res = await configItemExist(
        +sessionStorage.getItem("developLowCodeId"),
        configItem
      );
      if (res?.code === 200) {
        return res.data;
      }
    },
    isttiaojianpanduan(methodBody, Body) {
      const obj = methodBody.find((item2) => item2.id === Body.parentId);
      if (obj) {
        if (![1, 16, 17].includes(obj.componentType)) {
          this.isttiaojianpanduan(methodBody, obj);
        } else {
          return {
            obj,
            flag: true,
          };
        }
      }
    },
    istxunhuankongzhi(methodBody, Body) {
      const obj = methodBody.find((item2) => item2.id === Body.parentId);
      if (obj) {
        if (![2, 3].includes(obj.componentType)) {
          this.istxunhuankongzhi(methodBody, obj);
        } else {
          return true;
        }
      }
    },
    methodChildCirculate(methodBody, Body) {
      if ([1, 16, 17, 2, 3].includes(Body.componentType)) {
        const parenttiaojian = this.isttiaojianpanduan(methodBody, Body);
        if (parenttiaojian?.flag) {
          if (this.istxunhuankongzhi(methodBody, parenttiaojian.obj)) {
            this.isChildCirculate = true;
            this.changeRadio = "1";
            if ([2, 3].includes(Body.componentType)) {
              //当前点击数据是循环判断，父级或祖级是条件判断，在往上找祖级是循环控制
              this.isChildCirculate = "循环";
            }
          }
        } else {
          if (this.istxunhuankongzhi(methodBody, Body)) {
            this.isChildCirculate = false;
          }
        }
      }
    },
    handleItem(item) {
      if (this.activeitemName != item.name) {
        this.handleClickTab(item);
      }
    },
    handleXDelete(name, idx) {
      this.titleLists.splice(idx, 1);
      if (this.activeitemName == name) {
        if (idx > 0) {
          const obj = this.titleLists[idx - 1];
          this.handleClickTab(obj);
        }
      }
    },
    packageComponent(num, currentComponent) {
      this.activeName = num;
      this.activeState = this.activeitemName;
      // this.handleadFangfaDelete("addfangfa");
      this.isClickCom = false;
      this.currentComponent = currentComponent;
    },
    async handleClickTab(obj) {
      this.activeitemName = obj.name;
      const flag = this.allLists.some((item) =>
        item.children.some((childItem) => childItem.title.includes(obj.name))
      );
      if (this.activeitemName.includes("编辑API")) {
        // this.activeName = 1;
        this.activeState = this.activeitemName;
        this.handleAPItable();
        this.$nextTick(() => {
          this.$refs.basicsssssComponents.$refs.basicComponents.handleEadit(
            obj.row
          );
          this.$refs.tree.setCurrentKey(null);
        });
      } else if (this.activeitemName.includes("接口逻辑")) {
        // this.activeName = 1;
        this.activeState = this.activeitemName;
        this.handleAddAPI(this.activeitemName, false);
        this.$nextTick(() => {
          this.$refs.basicsssssComponents.$refs.basicComponents.interfaceInformation =
            obj.row;
          this.$refs.basicsssssComponents.$refs.basicComponents.interface_Information =
            JSON.parse(JSON.stringify(obj.row));
          if (
            !this.$refs.basicsssssComponents.$refs.basicComponents
              .interfaceInformation.service
          ) {
            this.$refs.basicsssssComponents.$refs.basicComponents.activeName =
              "first";
          }
          this.$refs.basicsssssComponents.$refs.basicComponents.handleLook();
          this.$refs.tree.setCurrentKey(null);
        });
      } else {
        if (flag) {
          if (this.activeitemName == "API列表") {
            this.activeName = 1;
            this.activeState = this.activeitemName;
            this.handleAPItable();
          } else if (this.activeitemName == "新增API") {
            this.activeName = 1;
            this.activeState = this.activeitemName;
            this.handleAddAPI("新增API", true);
          } else if (this.activeitemName == "数据库操作组件列表") {
            this.packageComponent(9, "customComponents");
          } else if (this.activeitemName == "数据库查询组件") {
            this.packageComponent(9, "customQuery");
          } else if (this.activeitemName == "数据库更新组件") {
            this.packageComponent(9, "customUpdates");
          } else if (this.activeitemName == "数据库删除组件") {
            this.packageComponent(9, "customDeletion");
          } else if (this.activeitemName == "数据库sql组件") {
            this.packageComponent(9, "customApiSearch");
          } else if (this.activeitemName == "通知配置列表") {
            this.packageComponent(11, "notificationListComponents");
          } else if (this.activeitemName == "新增短信或邮件通知模板") {
            this.packageComponent(11, "notificationComponents");
          } else if (this.activeitemName == "短信通知密钥设置") {
            this.packageComponent(11, "keySettingsComponents");
          } else if (this.activeitemName == "新增配置项") {
            this.packageComponent(11, "addconfigurationComponents");
          } else if (this.activeitemName == "新增短信签名") {
            this.packageComponent(11, "addSignature");
          } else if (this.activeitemName == "邮件通知设置") {
            this.packageComponent(11, "emailSettings");
          } else if (this.activeitemName == "周期性定时任务列表") {
            this.packageComponent(12, "scheduledTaskslists");
          } else if (this.activeitemName == "定时任务流程列表") {
            this.packageComponent(12, "scheduledFixedTaskLists");
          } else if (this.activeitemName == "feign调用接口列表") {
            this.packageComponent(14, "feignComponents");
          } else if (this.activeitemName == "新增feign调用接口") {
            this.packageComponent(14, "addinterfaceComponents");
          } else if (this.activeitemName == "依赖配置") {
            sessionStorage.setItem("activeState", "依赖配置");
            this.packageComponent(15, "dependencysConfiguration");
          } else if (this.activeitemName == "项目配置") {
            sessionStorage.setItem("activeState", "项目配置");
            this.packageComponent(15, "projectsConfiguration");
          } else if (this.activeitemName == "其他配置") {
            sessionStorage.setItem("activeState", "其他配置");
            this.packageComponent(15, "othersConfigurations");
          }
          this.$nextTick(async () => {
            this.$refs.tree.setCurrentKey(null);
          });
        } else {
          this.activeState = "";
          this.isClickCom = false;
          this.currentComponent = "basicsssssComponents";
          if (obj.btnName == "显示源码") {
            //按钮显示显示源码
            this.btnName = "显示源码";
            this.modeTitle = "显示源码";
            // await this.moduleModetTreeList();
            this.$nextTick(() => {
              const currentObj =
                this.$refs.basicsssssComponents.$refs.basicComponents;
              if (currentObj) {
                currentObj.isShowTable = false;
                currentObj.isapi = false;
                currentObj.isClicktree = true;
                currentObj.activeIndex = undefined;
                currentObj.addBasicObj.isMethodObjOrBody = null;
                currentObj.clicktreeInformation.controller =
                  obj.controllerOrservice;
                currentObj.clicktree_Information.controller = JSON.parse(
                  JSON.stringify(obj.controllerOrservice)
                );
                this.activeitemName = obj.controllerOrservice.className;
                currentObj.classType = obj.controllerOrservice.classType;
                const dom = document.getElementById(obj.svg);
                dom.parentElement.scrollLeft = dom.offsetLeft;
                setTimeout(() => {
                  currentObj.someSourceCode.content = obj.someSourceCodeContent;
                  currentObj.statusLogic(obj);
                });
              }
            });
            // this.fengzhuangConent(obj.classId);
          } else {
            //按钮显示显示模块
            this.btnName = "显示模块";
            this.modeTitle = "显示模块";
            // await this.SourceCodeTreeList();
            this.projectgetContent(obj.classId);
            this.$nextTick(async () => {
              const dom = document.getElementById(obj.svg);
              dom.parentElement.scrollLeft = dom.offsetLeft;
            });
          }
          // this.$refs.tree.filter(this.filterText);
          // this.treeGaoliangAndscroll(obj.classId);
        }
      }
    },
    async projectgetContent(id) {
      const index = this.formData.labeName.indexOf(".");
      if (index > 0 && index < this.formData.labeName.length - 1) {
        // this.formData.content = "";
        const res = await projectgetContent(id);
        if (res?.code === 200) {
          this.formData.content = res.data;
        }
      }
    },
    treeGaoliangAndscroll(classId) {
      this.$nextTick(async () => {
        this.$refs.tree.setCurrentKey(classId);
        await this.$nextTick();
        const dom = document.querySelectorAll(".is-current");
        const domscrollbar = document.querySelector("#elScrollbar");
        const { top } = getOffsetTopToScrollParent(dom, domscrollbar);
        domscrollbar.scrollTop = top;
      });
    },

    handleAPItable() {
      this.activeitemName = "API列表";
      this.currentComponent = "basicsssssComponents";
      this.isClickCom = false;
      if (this.btnName != "显示源码") {
        this.btnName = "显示源码";
        this.modeTitle = "显示源码";
        this.moduleModetTreeList();
      }
      this.$nextTick(() => {
        this.$refs.basicsssssComponents.$refs.basicComponents.isShowTable = true;
        this.$refs.basicsssssComponents.$refs.basicComponents.isapi = true;
        // this.handleadFangfaDelete("addfangfa");
        this.$refs.basicsssssComponents.$refs.basicComponents.isClicktree = false;
        this.$refs.basicsssssComponents.$refs.basicComponents.getList();
        this.$refs.basicsssssComponents.$refs.basicComponents.activeIndex =
          undefined;
        this.$refs.basicsssssComponents.$refs.basicComponents.addBasicObj.isMethodObjOrBody =
          null;
        this.$refs.basicsssssComponents.$refs.basicComponents.fengzhuang();
      });
    },
    handleAddAPI(name, flag) {
      this.activeitemName = name;
      this.currentComponent = "basicsssssComponents";
      this.isClickCom = false;
      if (this.btnName != "显示源码") {
        this.btnName = "显示源码";
        this.modeTitle = "显示源码";
        this.moduleModetTreeList();
      }
      this.$nextTick(() => {
        this.$refs.basicsssssComponents.$refs.basicComponents.isShowTable = false;
        this.$refs.basicsssssComponents.$refs.basicComponents.isapi = flag;
        // this.handleadFangfaDelete("addfangfa");
        this.$refs.basicsssssComponents.$refs.basicComponents.isClicktree = false;
        this.$refs.basicsssssComponents.$refs.basicComponents.btnTitle =
          "生成接口基础信息";
        if (name == "新增API") {
          this.$refs.basicsssssComponents.$refs.basicComponents.$refs[
            "dialogForm"
          ].clearValidate();
          const AddApiobj = this.titleLists.find(
            (item) => item.name === "新增API"
          );
          if (AddApiobj && AddApiobj.row) {
            console.log("clearValidate888888888");

            this.$refs.basicsssssComponents.$refs.basicComponents.formData =
              AddApiobj.row;
          }
        }
        this.$refs.basicsssssComponents.$refs.basicComponents.fengzhuang();
      });
    },
    //feign调用中选择feign接口选择+
    handleFeignDesPackage() {
      this.activeName = 14;
      this.activeState = "新增feign调用接口";
      this.handlePackage(
        "新增feign调用接口",
        "addinterfaceComponents",
        "addinterface"
      );
    },
    handleTable(activeitemName, currentComponent) {
      // this.handleadFangfaDelete("addfangfa");
      this.isClickCom = false;
      this.activeitemName = activeitemName;
      this.currentComponent = currentComponent;
    },
    handledTableBtnSave(name, componentName, currentComponent) {
      this.activeState = componentName;
      sessionStorage.setItem("activeState", componentName);
      this.handleTable(componentName, currentComponent);
      let svg = "";
      if (currentComponent == "customComponents") {
        this.activeName = 9;
        svg = "dbseCaozuo";
      } else if (currentComponent == "notificationListComponents") {
        this.activeName = 11;
        svg = "tongzhiliebiao";
      } else if (currentComponent == "feignComponents") {
        this.activeName = 14;
        svg = "jiekouliebiao";
      } else {
        this.activeName = undefined;
        svg = "";
      }
      this.isaddTitleLists(svg);
      const idx = this.titleLists.findIndex((item) => item.name == name);
      this.titleLists.splice(idx, 1);
    },
    isaddTitleLists(svg, row) {
      const obj = this.titleLists.find((item) => item.svg === svg);
      if (!obj) {
        this.titleLists.push({
          name: this.activeitemName,
          svg,
          row,
        });
        this.$nextTick(() => {
          const dom = document.getElementById(svg);
          dom?.scrollIntoView({ behavior: "smooth", inline: "center" });
        });
      } else {
        // 加上这句有可能其他地方有问题
        obj.row = row;
        // 加上这句有可能其他地方有问题

        this.$nextTick(() => {
          const dom = document.getElementById(obj.svg);
          dom?.scrollIntoView({ behavior: "smooth", inline: "center" });
        });
      }
    },
    handlePackage(activeitemName, currentComponent, svg) {
      // this.handleadFangfaDelete("addfangfa");
      this.isClickCom = false;
      this.activeitemName = activeitemName;
      this.currentComponent = currentComponent;
      this.isaddTitleLists(svg);
    },
    async handleState(state, svg) {
      this.activeState = state;
      sessionStorage.setItem("activeState", state);
      // 打断当前循环组件和结束循环组件
      if (svg == "BreakComponent" || svg == "overCompoent") {
        const basicComponents =
          this.$refs.basicsssssComponents?.$refs.basicComponents;
        this.methodChildCirculate(
          basicComponents.addBasicObj.item.methodBody,
          basicComponents.addBasicObj.isMethodObjOrBody
        );
      } else {
        this.isChildCirculate = true;
        this.changeRadio = "1";
      }
      if (state == "增加方法") {
        if (this.$refs.basicsssssComponents) {
          if (!this.$refs.basicsssssComponents.$refs.basicComponents.isapi) {
            this.$refs.basicsssssComponents.$refs.basicComponents.diaMethodVisible = true;
          }
        }
      } else if (state == "API列表") {
        this.handleAPItable();
        this.isaddTitleLists(svg);
      } else if (state == "新增API") {
        this.handleAddAPI("新增API", true);
        this.isaddTitleLists(svg);
      } else if (state == "新增vo") {
        this.$store.state.user.objServicedelog = true;
      } else if (state == "新增类") {
        this.addClassVisible = true;
      } else if (state == "数据库操作组件列表") {
        this.handleTable("数据库操作组件列表", "customComponents");
        this.isaddTitleLists(svg);
      } else if (state == "数据库查询组件") {
        this.handlePackage("数据库查询组件", "customQuery", svg);
      } else if (state == "数据库更新组件") {
        this.handlePackage("数据库更新组件", "customUpdates", svg);
      } else if (state == "数据库删除组件") {
        this.handlePackage("数据库删除组件", "customDeletion", svg);
      } else if (state == "数据库sql组件") {
        this.handlePackage("数据库sql组件", "customApiSearch", svg);
      } else if (state == "通知配置列表") {
        this.handleTable("通知配置列表", "notificationListComponents");
        this.isaddTitleLists(svg);
      } else if (state == "新增短信或邮件通知模板") {
        this.handlePackage(
          "新增短信或邮件通知模板",
          "notificationComponents",
          svg
        );
      } else if (state == "短信通知密钥设置") {
        const res = await this.handletemplateBlur("smsAccess");
        if (res) {
          return this.$message({
            message: `短信通知密钥设置已存在，请到通知配置列表编辑`,
            type: "warning",
            showClose: true,
          });
        }
        this.handlePackage("短信通知密钥设置", "keySettingsComponents", svg);
      } else if (state == "新增配置项") {
        this.handlePackage("新增配置项", "addconfigurationComponents", svg);
      } else if (state == "新增短信签名") {
        this.handlePackage("新增短信签名", "addSignature", svg);
      } else if (state == "邮件通知设置") {
        const res = await this.handletemplateBlur("emailConfig");
        if (res) {
          return this.$message({
            message: `邮件通知设置已存在，请到通知配置列表编辑`,
            type: "warning",
            showClose: true,
          });
        }
        this.handlePackage("邮件通知设置", "emailSettings", svg);
      } else if (svg == "dingshirenwu") {
        this.scheduledTasksVisible = true;
      } else if (svg == "renwuliucheng") {
        this.scheduledFixedTasksVisible = true;
      } else if (svg == "zhouqixingliebiao") {
        this.handlePackage("周期性定时任务列表", "scheduledTaskslists", svg);
      } else if (svg == "dingshixingliebiao") {
        this.handlePackage("定时任务流程列表", "scheduledFixedTaskLists", svg);
      } else if (svg == "jiekouliebiao") {
        this.handlePackage("feign调用接口列表", "feignComponents", svg);
      } else if (svg == "addinterface") {
        this.handlePackage("新增feign调用接口", "addinterfaceComponents", svg);
      } else if (svg == "dependencyConfiguration") {
        this.handlePackage("依赖配置", "dependencysConfiguration", svg);
      } else if (svg == "projectConfiguration") {
        this.handlePackage("项目配置", "projectsConfiguration", svg);
      } else if (svg == "otherConfigurations") {
        this.handlePackage("其他配置", "othersConfigurations", svg);
      }

      this.$nextTick(() => {
        const basicComponents =
          this.$refs.basicsssssComponents?.$refs.basicComponents;
        if (!basicComponents) return;
        if (basicComponents.activeIndex) {
          if (
            basicComponents.activeIndex.endsWith("方法高亮") ||
            basicComponents.activeIndex.endsWith("方法体高亮")
          ) {
            // ["增加方法","新增vo","新增类","添加周期性定时任务","新增定时任务流程"]
            if (
              [
                "addfangfa",
                "vosvg",
                "addClasswe",
                "dingshirenwu",
                "renwuliucheng",
              ].includes(svg)
            ) {
              return;
            }
            if (basicComponents.addBasicObj.isMethodOrBody == "方法") {
              if (
                basicComponents.classType !== "DAO" &&
                basicComponents.classType !== "SERVICE_I"
              ) {
                basicComponents.handleClick2(
                  basicComponents.addBasicObj.isMethodObjOrBody
                );
              }
            }
            if (basicComponents.addBasicObj.isMethodOrBody == "方法体") {
              if (
                !basicComponents.isdbcaozuozujian.includes(
                  basicComponents.addBasicObj.isMethodObjOrBody.componentType
                )
              ) {
                // basicComponents.isContains
                if (
                  basicComponents.isContains.includes(
                    basicComponents.addBasicObj.isMethodObjOrBody.componentType
                  )
                ) {
                  if (this.isChildCirculate) {
                    if (this.isChildCirculate === "循环") {
                      //同层
                      basicComponents.handleClick3(
                        basicComponents.addBasicObj.item,
                        basicComponents.addBasicObj.isMethodObjOrBody,
                        true,
                        basicComponents.addBasicObj.index3,
                        basicComponents.addBasicObj.item.methodBody
                      );
                    } else {
                      this.changeDialogVisible = true;
                    }
                  } else {
                    //子层
                    basicComponents.handleClick3(
                      basicComponents.addBasicObj.item,
                      basicComponents.addBasicObj.isMethodObjOrBody,
                      undefined,
                      undefined,
                      basicComponents.addBasicObj.item.methodBody
                    );
                  }
                } else {
                  basicComponents.handleClick3(
                    basicComponents.addBasicObj.item,
                    basicComponents.addBasicObj.isMethodObjOrBody,
                    undefined,
                    undefined,
                    basicComponents.addBasicObj.item.methodBody
                  );
                }
              }
            }
          }
        }
      });
    },
    handleChangeSure() {
      this.changeDialogVisible = false;
      this.$nextTick(() => {
        const basicComponents =
          this.$refs.basicsssssComponents?.$refs.basicComponents;
        if (!basicComponents) return;
        if (this.changeRadio === "1") {
          //同层
          basicComponents.handleClick3(
            basicComponents.addBasicObj.item,
            basicComponents.addBasicObj.isMethodObjOrBody,
            true,
            basicComponents.addBasicObj.index3,
            basicComponents.addBasicObj.item.methodBody
          );
        } else {
          //子层
          basicComponents.handleClick3(
            basicComponents.addBasicObj.item,
            basicComponents.addBasicObj.isMethodObjOrBody,
            undefined,
            undefined,
            basicComponents.addBasicObj.item.methodBody
          );
        }
      });
    },

    handleNodeClick(data, node) {
      this.currentComponent = "basicsssssComponents";
      this.formData.labeName = data.name;
      this.closeMenu();
      if (this.btnName === "显示模块") {
        this.modeTitle = "显示模块";
        if ([4, 5, 6, 8].includes(data.type)) {
          const idx = data.name.indexOf(".");
          const name = data.name.slice(0, idx);
          const obj = this.titleLists.find((item) => item.name === name);
          if (!obj) {
            this.titleLists.push({
              classId: data.id,
              name,
              svg: name,
              btnName: "显示模块",
            });
            this.$nextTick(async () => {
              if (name) {
                const dom = document.getElementById(name);
                dom.parentElement.scrollLeft = dom.offsetLeft;
              }
            });
          }
          this.activeitemName = name;
          this.projectgetContent(data.id);
        }
      } else {
        this.modeTitle = "显示源码";
        const parentDate = node.parent.data;
        if (
          [4, 5, 8].includes(data.type) ||
          [4, 5, 8].includes(parentDate.type)
        ) {
          this.activeState = "";
          this.isClickCom = false;
          const _id = [4, 5, 8].includes(data.type)
            ? data.id
            : [4, 5, 8].includes(parentDate.type)
            ? parentDate.id
            : "";
          this.fengzhuangConent(_id);
          console.log(_id, "clicktree");
        }
      }
    },
    handleadFangfaDelete(name) {
      if (this.isgaoliangLists.includes(name)) {
        const index = this.isgaoliangLists.indexOf(name);
        if (index >= 0) {
          this.isgaoliangLists.splice(index, 1);
        }
      }
    },
    handleadFangfaAdd(name) {
      if (!this.isgaoliangLists.includes(name)) {
        this.isgaoliangLists.push(name);
      }
    },
    fengzhuangConent(classId) {
      this.$nextTick(() => {
        this.$refs.basicsssssComponents.$refs.basicComponents.isShowTable = false;
        this.$refs.basicsssssComponents.$refs.basicComponents.isapi = false;
        // this.handleadFangfaAdd("addfangfa");
        this.$refs.basicsssssComponents.$refs.basicComponents.isClicktree = true;
        this.$refs.basicsssssComponents.$refs.basicComponents.componentClassjson(
          classId
        );
        this.$refs.basicsssssComponents.$refs.basicComponents.activeIndex =
          undefined;
        this.$refs.basicsssssComponents.$refs.basicComponents.addBasicObj.isMethodObjOrBody =
          null;
      });
    },
    handleClick() {
      this.filterText = "";
      if (this.btnName === "显示源码") {
        this.btnName = "显示模块";
        this.SourceCodeTreeList();
        this.expandLists = [];
      } else {
        this.btnName = "显示源码";
        this.moduleModetTreeList();
        this.$nextTick(() => {
          if (this.$refs.basicsssssComponents) {
            this.$refs.basicsssssComponents.$refs.basicComponents.getList();
          }
        });
      }
    },
    filterNode(value, data) {
      if (!value) return true;
      return data.name.indexOf(value) !== -1;
    },
    async SourceCodeTreeList() {
      try {
        this.treeLoading = true;
        const res = await SourceCodeTreeList(
          +sessionStorage.getItem("developLowCodeId")
        );
        this.treeLoading = false;
        if (res?.code === 200) {
          this.treeData = res.data;
          this.$nextTick(() => {
            this.$refs.tree.filter(this.filterText);
          });
        }
      } catch (err) {
        this.treeLoading = false;
      }
    },
    recursion(lists) {
      lists.forEach((item) => {
        if (item.type <= 2) {
          this.expandLists.push(item.id);
          console.log(this.expandLists, 22222222222);
          if (Array.isArray(item.list)) {
            this.recursion(item.list);
          }
        }
      });
    },
    async moduleModetTreeList() {
      try {
        console.time("时间");
        this.treeLoading = true;
        const res = await moduleModetTreeList(
          +sessionStorage.getItem("developLowCodeId")
        );
        this.treeLoading = false;
        console.timeEnd("时间");
        if (res?.code === 200) {
          this.treeData = res.data;
          this.expandLists = [];
          this.recursion(this.treeData);
          this.$nextTick(() => {
            this.$refs.tree.filter(this.filterText);
          });
        }
      } catch (err) {
        this.treeLoading = false;
      }
    },
  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val);
    },
    titleLists: {
      handler(newVal) {
        const flag = newVal.find((item) => item.svg == "APIpre");
        if (!flag) {
          this.$refs.basicsssssComponents.$refs.basicComponents.$refs[
            "dialogForm"
          ].clearValidate();
          this.$refs.basicsssssComponents.$refs.basicComponents.formData = {
            packageName: "",
            requestChName: "",
            requestName: "",
            requestType: "get",
            baseRequestUrl: "",
            returnType: "String",
            return_Type: "String | 字符串",
            requestParams: [
              {
                paramsName: "",
                paramsType: "String",
                params_Type: "String | 字符串",
              },
            ],
            isSysLog: "true",
            moduleId: undefined,
          };
          this.$refs.basicsssssComponents.$refs.basicComponents.activeIndex =
            undefined;
          this.$refs.basicsssssComponents.$refs.basicComponents.addBasicObj.isMethodObjOrBody =
            null;
        }
      },
    },
    activeitemName(newval, oldval) {
      if (oldval == "新增API") {
        const AddApiobj = this.titleLists.find(
          (item) => item.name === "新增API"
        );
        if (AddApiobj) {
          AddApiobj.row = JSON.parse(
            JSON.stringify(
              this.$refs.basicsssssComponents.$refs.basicComponents.formData
            )
          );
          console.log(AddApiobj.row, "activeitemName");
        }
      }
    },
  },
};
</script>




<style lang="scss" scoped>
.fiexleft,
.fiexright {
  position: fixed;
  top: 32px;
  font-size: 40px;
  z-index: 100;
  cursor: pointer;
}
.bottomOrTop {
  color: #13192b;
  position: absolute;
  top: -27px;
  // left: 48.5%;
  font-size: 40px;
  z-index: 2;
  cursor: pointer;
}
.myFooter {
  width: 100%;
  position: absolute;
  height: 1px;
  bottom: 0px;
  left: 0px;
  background: white;
  border-top: 1px solid #ccc;
  box-sizing: border-box;
  z-index: 100;
  text-align: center;
  transition: all 1s ease;
}
.childClass {
  padding-left: 18px;
  padding-right: 30px;
  padding-top: 20px;
  padding-bottom: 10px;
  height: 100%;
}
.resizeTOPBar {
  cursor: row-resize;
  height: 5px;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
}
.showConent {
  padding: 20px 50px;
  text-align: center;
}
.mgl {
  margin-left: 7px;
}
.mgl15 {
  margin-left: 15px;
}
.colorStyle {
  border: 1px solid white;
  cursor: pointer;
}
.color_Style {
  cursor: pointer;
}
.classssStyle {
  float: left;
  margin-top: 8px;
  margin-right: 8px;
  margin-left: 8px;
}
.leftAside,
.rightAside {
  padding: 0 !important;
  margin-bottom: 0;
  position: relative;
  transition: all 1s ease;
  background: #13192b !important;
}
.leftAside {
  padding-top: 26px !important;
  overflow: auto;
  color: white;
  font-size: 12px;
}
.rightAside {
  border-left: 1px solid #ccc !important;
  .el-tree {
    background-color: #13192b !important;
    color: #999b9d;
  }
}
.imgsvg {
  width: 18px;
  height: 18px;
  margin: 7px;
  cursor: pointer;
}
.borderColor {
  overflow: hidden;
  border-bottom: 1px solid #151515;
}
.borderColor .imgsvg {
  float: left;
}
.classStyle {
  display: flex;
  justify-content: center;
  padding: 10px 0;
}
.el-scrollbar {
  position: relative;
  display: inline-block;
  height: calc(100vh - 200px);
  background-color: #13192b !important;
  color: #999b9d;
  width: 100%;
  ::v-deep .el-tree-node:focus > .el-tree-node__content {
    background: white;
  }
}

.classFixed {
  text-align: center;
  transition: all 1s ease;
}
.elCollapseStyle {
  height: calc(100vh - 126px);
  overflow-y: auto;
  .collapse-title {
    flex: 1 0 90%;
    order: 1;
    font-size: 12px;
  }
  ::v-deep .el-collapse {
    border-top: none;
  }
  ::v-deep .el-collapse-item__header {
    background-color: #13192b !important;
    color: white;
    padding-left: 10px;
  }
  ::v-deep .el-collapse-item__wrap {
    background-color: #13192b !important;
  }
  ::v-deep .el-collapse-item__content {
    padding-bottom: 0;
  }
}

.setctionBox {
  padding-left: 10px;
  margin-top: 5px;
  display: flex;
  flex-wrap: wrap;
  a {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 5px;
    margin-bottom: 10px;
    text-align: center;
    width: 55px;
    cursor: pointer;
    span {
      line-height: 15px;
      margin-top: 3px;
      font-size: 12px;
    }
  }
}
.talin {
  margin-left: 12px;
}
.header {
  font-weight: bolder;
  font-size: 17px;
  background: linear-gradient(to right, #304156, #13192b, #304156);
  color: white;
  display: flex;
  align-items: center;
  padding: 0px 12px;
  line-height: 40px;
}
.mlt10 {
  margin-right: auto;
}
.resizeBar {
  cursor: col-resize;
  position: absolute;
  width: 5px;
  height: 100%;
  left: 0;
  top: 0;
}
.elMain {
  // padding-top: 10px;
  padding-bottom: 0;
  position: relative;
  overflow: hidden;
}
.deleteX {
  padding: 2px 5px;
  border-radius: 50%;
  font-size: 12px;
  word-break: break-all;
}
.deleteX:hover {
  background: #ccc;
}
.itemClass {
  padding: 5px;
  border: 1px solid #ccc;
  margin-right: 3px;
  border-radius: 5px;
  white-space: nowrap;
  cursor: pointer;
}
.box_Item {
  display: flex;
  overflow: auto;
  position: relative;
  padding-bottom: 2px;
  margin-bottom: 10px;
  scroll-behavior: smooth;
}
.contextmenu {
  margin: 0;
  background: #fff;
  z-index: 3000;
  position: fixed;
  list-style-type: none;
  padding: 5px 0;
  padding-top: 15px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 400;
  color: #333;
  box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3);
  li {
    margin: 0;
    padding: 7px 16px;
    cursor: pointer;
    &:hover {
      color: #1890ff;
    }
  }
}
.successorerror {
  max-height: 97%;
  overflow: auto;
  border: 1px solid #ebe7e7;
  text-align: left;
}
.classError {
  color: red;
  margin-left: 55px;
  height: 97%;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
<style>
body {
  width: 100vw;
  overflow: hidden;
  /* padding-left: calc(100vw - 100%); */
}
</style>
